$(function(){
    
    $(document).ready(function() {
          
        // hide video and reset css on the pixel background when not on home page
        //var $frontVideo = $('#front-video');
        var $mainBg = $('.main-bg');
        var $pixelBg = $('.pixel-bg');
        var pathname = window.location.pathname;
        
        if(pathname == '/' || pathname == '/en') {

            
        } else {
            $pixelBg.css('position', 'static');
            $pixelBg.css('background-attachment', 'fixed');
        }
        
        
        
       // drop-down menu toggle
        $('.show-all-products').on('mouseenter', function(e) {
            
            //e.preventDefault();
            
            $('#drop-down-all-products').slideDown(400);
            
            $('#drop-down-all-products').on('mouseleave', function() {
                
                $('#drop-down-all-products').stop().slideUp(100);
            });
            
            $('#drop-contacts').slideUp(50);
            $('#header-login').slideUp(50); 
            $('#header-search').slideUp(50);
            $('#cart').hide(50);
    
        });
        
        // handle responsive menu button, size and behavior
        $windowWidth = $(window).width();
        $windowHeight = $(window).height() - 90;
        
        if($windowWidth < 481) {
            $('#menu-button').show();
            $('#drop-down-all-products').css('height', $windowHeight);
        }
        
        $('#menu-button').on('click', function() {     
            
            $('#drop-down-all-products').slideToggle(400);
            
            $('#drop-contacts').slideUp(50);
            $('#header-login').slideUp(50); 
            $('#header-search').slideUp(50);
            $('#cart').hide(50);
            
        });
        
        $('#show-contacts').on('mouseenter', function(e) {
            
            //e.preventDefault();
            
            $('#drop-contacts').stop().slideDown(400, function() {
                initialize("42.670163","23.354039", "dropdown-map");
            });
            
            $('#drop-contacts').on('mouseleave', function() {
                
                $('#drop-contacts').stop().slideUp(100);
            });
            
            $('#drop-down-all-products').stop().slideUp(50);
            $('#header-login').slideUp(50); 
            $('#header-search').slideUp(50);
            $('#cart').hide(50);
            
            

        });
        
        // search bar toggle slide 
        $('#search-icon').on('click', function(e) {
            
			e.preventDefault();
                   
            $('#drop-down-all-products').slideUp(50);
            $('#drop-contacts').slideUp(50);
            $('#header-login').slideUp(50); 
            $('#cart').hide(50);
            
            
            $('#header-search').slideToggle(100);
            $('#header-search input').focus();
			
        });
        
        $('#search-icon').hover(function() {
            
			$('#search-hover').toggle();
			
        });
        
        // login bar toggle slide
        $('#profile').on('click', function(e) {
            
			e.preventDefault();            
            
            $('#drop-down-all-products').slideUp(50); 
            $('#drop-contacts').slideUp(100);
            $('#header-search').slideUp(50);
            
            $('#header-login').slideToggle(100);
            $('#header-login input#user-email').focus();
			
        });
        
        $('#profile').hover(function() {
            
			$('#profile-hover').toggle();
			
        });
        
        // cart toggle slide
        $('#cart-icon').on('click', function(e) {
            
			e.preventDefault();           
            
            $('#drop-down-all-products').slideUp(50); 
            $('#drop-contacts').slideUp(100);
            $('#header-login').slideUp(50); 
            $('#header-search').slideUp(50); 
            
            $('#cart').slideDown(50);

        });
        
        // flag class active toggle 
        $('#bg').click(function() {
            $(this).addClass('active');
            $('#en').removeClass('active');
        });
        $('#en').click(function() {
            $(this).addClass('active');
            $('#bg').removeClass('active');
        });
        
        //landing animations 
        $('#inner-headline-top').delay(400).animate({top: '+=55px'}, 200, function() {
            $('#inner-headline-bottom').animate({top: '+=55px'}, 400);
        });
        
        $('#inner-label-top').delay(1200).animate({left: '0px'}, 300, function() {  
            $('#label-top-triangle').animate({top: '40px'}, 200);       
        });
        
        $('#inner-label-left').delay(1300).animate({right: '0px'}, 300, function() {  
            $('#label-left-triangle').animate({top: '40px'}, 200);
        });
        
        $('#inner-label-right').delay(1400).animate({left: '0px'}, 300, function() {  
            $('#label-right-triangle').animate({top: '3px'}, 200);
        });
        
        // cart icon display toggle
        var cart = $('#cart-counter-icon');
        var displayCart = false;
        
        cart.change(function() {
            
            var value = parseInt(cart.innerHTML);
            
            if(value > 0) {
                
            }
            
        });
        
        // banners show animation
        var $weatherBanner = $('#banner-weather');
        var $banners = $('#container-banners');
        var $forecast = $('#container-forecast');
        
        $weatherBanner.stop().on('mouseenter', function() {
            $forecast.animate({top: "0"}, 200);
            $banners.animate({top: "-124px"}, 200);
        });
        $forecast.on('mouseleave', function() {
            $forecast.animate({top: "124px"}, 200);
            $banners.animate({top: "0"}, 200);
        });
        
        // options toggle active class
        var $options = $('.sf-option img');
        
        // hide notifications
        $('#notification').on('click', '.close', function() {
            $('.success, .warning, .attention, .error').fadeOut('slow');
        });
              
    });
}());


